/***************************************************
> Copyright (C) 2024 ==KINGYI== All rights reserved.
> File Name:type.c
> Author:xxx
> Mail: 
> Created Time: 2024年12月04日 星期三 16时08分15秒
***************************************************/

#include "cJSON.h"
#include "style.h"

int cjson_type(char *str){
	//将标准json格式字符串转换为json对象
	cJSON *root = cJSON_Parse(str);
	
	cJSON *type = cJSON_GetObjectItem(root,"type");
	
	//获取字符串类型的值
	char *type_1 = cJSON_GetStringValue(type);
	printf("%s\n",type_1);
	if(strcmp(type_1,"gly_login")){
		return 1;
	}else if(strcmp(type_1,"staff_login") == 0){
		return 2;
	}else if(strcmp(type_1,"family_login") == 0){
		return 3;
	}else if(strcmp(type_1,"family_register") == 0){
		return 4;
	}
	return 0;
}

//判断管理员是否登陆成功
int gly_login(int client_socket,char *str){
	//将标准json格式字符串转换为json对象
	cJSON *root = cJSON_Parse(str);
	
	cJSON *username = cJSON_GetObjectItem(root,"username");
	cJSON *passwd = cJSON_GetObjectItem(root,"passwd");
	
	char *username_1 = cJSON_GetStringValue(username);
	char *passwd_1 = cJSON_GetStringValue(passwd);
	
	if(strcmp(username_1,"gly") == 0 && strcmp(passwd_1,"123456") == 0){
		write(client_socket,"succsee",7);
		return 1;
	}else{
		write(client_socket,"file",4);
		return 0;
	}
}









